<?
require("config.php");

$Query = "SELECT 

code,
aid,
date,
first_name,
last_name,
position,
company,
c_address,
p_address,
email,
o_phone,
m_phone,
h_phone,
status
FROM $table";

$r=myQuery($Query);


header("Content-type:application/vnd.ms-excel");  
header("Content-Disposition:filename=subscription_" . date("Ymd") . ".xls");  

echo "code\t";
echo "acuity evening\t";
echo "date\t";
echo "first name\t";
echo "last name\t";
echo "position\t";
echo "company\t";
echo "company address\t";
echo "private address\t";
echo "email\t";
echo "office phone\t";
echo "mobile phone\t";
echo "home phone\t";
echo "status\t\n";

for ($i=0;$i<count($r);$i++){

echo $r[$i][0] . "\t"; 
$Query = "select presented from med_aevening where id='".$r[$i][1]."'";
$r1 = myQuery($Query);

echo $r1[0][0] . "\t"; 
echo $r[$i][2] . "\t"; 
echo $r[$i][3] . "\t"; 
echo $r[$i][4] . "\t"; 
echo $r[$i][5] . "\t"; 
echo $r[$i][6] . "\t"; 
echo $r[$i][7] . "\t"; 
echo $r[$i][8] . "\t"; 
echo $r[$i][9] . "\t"; 
echo $r[$i][10] . "\t"; 
echo $r[$i][11] . "\t"; 
echo $r[$i][12] . "\t"; 
echo $r[$i][13] . "\t\n"; 
}
?>